#include <iostream>
#include <string>
#include <set>
using namespace std;

bool checkRecord(string s) {
    set<int> recset;
    int ba=0;
    for(int i=0;i < s.size(); ++i){
        if(s[i] == 'A'){
            ++ba;
            if(ba >= 2)
                return false;
        }
        if(s[i] == 'L'){
            if(recset.find(i-1) != recset.end() && recset.find(i-2) != recset.end()){
                return false;
            }else{
                recset.insert(i);
            }
        }
    }
    return true;

}

int main(int argc, char const *argv[])
{
    string a="PPALLL";
    cout<<checkRecord(a)<<endl;
    return 0;
}

